﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO; 

namespace DupeKill.Core.Reporting
{
    public class XmlReportGenerator : IReportGenerator 
    {
        private StreamWriter writer; 
        public XmlReportGenerator(string file)
        {
            writer = new StreamWriter(file);
            writer.WriteLine("<report>"); 
        }
        #region IReportGenerator Member

        public void Append(FileSet fileSet)
        {
            if (fileSet.Count > 1)
            {
                writer.WriteLine(string.Format("\t<fileSet size=\"{0}\">", fileSet.Count * fileSet[0].Length));

                for (int i = 0; i < fileSet.Count; i++)
                {
                    writer.WriteLine(string.Format("\t\t<file>{0}</file>",fileSet[i].FullPath)); 
                }

                writer.WriteLine("\t</fileSet>");
            }
        }

        public void Flush()
        {
            writer.WriteLine("</report>");
            writer.Flush();
            writer.Close(); 
        }

        #endregion
    }
}
